{extend name=".././view/create.html" /}
{block name="jscss"}
<style type="text/css">
  .srcSelectStyly{
    /*margin-top:20px;*/
    border-width: 1px;
    border-color:#e2e2e2;
    border-style:solid;
    background-color:#ffffff;
    position:absolute;
    left:0;
    right:0;
    z-index:100;
  }
  .srcSelectStyly dl{
    padding-top: 3px;
    padding-left: 6px;
    background-color:#ffffff;
  }
  .srcSelectStyly dd{
    /*margin-bottom: 3px;*/
    /*background-color:#f2f2f2;*/
    height: 30px;
    padding-top: 10px;
  }
</style>
{/block}
{block name="form"}
    <div class="layui-form-item" align="center">
      {eq name="$list.set.formpost" value="PUT" }
        {if strlen($list.data.url)>0}
          <img id="img" style="max-height: 300px;max-width: 500px" src="__UPLOAD__/{$list.data.url}" onclick="imgMax(this,true)">
        {else /}
          <img id="img" style="max-height: 300px;max-width: 500px" src="__UPLOAD__/rongyu_teacher/404.png" onclick="imgMax(this,true)">
        {/if}
      {/eq}
      {eq name="$list.set.formpost" value="POST" }
          <img id="img" style="max-height: 300px;max-width: 500px" src="" onclick="imgMax(this,true)">
      {/eq}
    </div>
    <form class="layui-form layui-form-pane" lay-filter="myform">
        <div class="layui-form-item">
              <label for="title" class="layui-form-label">
                  图片
              </label>
              <div class="layui-inline">
                <div class="layui-input-inline" style="min-width: 300px">
                  <input type="text" id="url" name="url"
                  autocomplete="off" class="layui-input " value="{$list.data.url|default=''}" placeholder="地址" readonly>
                </div>
                <div class="layui-input-inline" style="min-width: 100px">
                  <button type="button" class="layui-btn" id="upload">
                    <i class="layui-icon">&#xe67c;</i>上传图片
                  </button>
                </div>

              </div>
          </div>
          <div class="layui-form-item">
              <label for="project" class="layui-form-label">
                  项目名称
              </label>
              <div class="layui-input-block">
                  <input type="text" id="project" name="project"
                  autocomplete="off" class="layui-input " value="{$list.data.project|default=''}" placeholder="中文1-100个字符">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="title" class="layui-form-label">
                  荣誉标题
              </label>
              <div class="layui-input-block">
                  <input type="text" id="title" name="title"
                  autocomplete="off" class="layui-input " value="{$list.data.title|default=''}" placeholder="中文1-100个字符">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="cyselect" class="layui-form-label">
                  参与人
              </label>
              <div class="layui-inline">
                <div class="layui-input-inline">
                  <input name="cySearch" id="cySearch" type="text" class="layui-input" autocomplete="off">
                </div>
                {present name="$list.data.cy_dwry"}
                  {volist name="$list.data.cy_dwry" id="vo"}
                  <div class="layui-input-inline" style="width:60px">
                    <div onclick="cjgl.delTeacher(this)" class="layui-btn layui-btn-normal">
                      {$vo.teacher.xingming}
                    </div>
                    <input type="hidden" name="teachers[]" value="{$vo.teacher.id}"></div>
                  {/volist}
                {/present}
              </div>
          </div>
          <div class="layui-form-item">
    		    <label for="category_id" class="layui-form-label"><span class="x-red">*</span>荣誉类型</label>
    		    <div class="layui-input-block">
    		    	{php} $category = categoryChildren(112);{/php}
    		      <select name="category_id" lay-verify="required">
    		      	<option value=""></option>
    		      	{volist name="category" id="vo"}
                  <option value="{$vo.id}"
                  {present name="$list.data.category_id"}
                    {eq name="$list.data.category_id" value="$vo.id" }
                      selected
                    {/eq}
                  {/present}>
                    {$vo.title}
                  </option>
    		        {/volist}
    		      </select>
    		    </div>
    		  </div>
          <div class="layui-form-item">
            <label for="hjschool_id" class="layui-form-label"><span class="x-red">*</span>获奖单位</label>
            <div class="layui-input-block">
              {php} $school = danweiJibie('校级','区级');{/php}
              <select name="hjschool_id" lay-verify="required">
                <option value=""></option>
                {volist name="school" id="vo"}
                  <option value="{$vo.id}"
                  {present name="$list.data.hjschool_id"}
                    {eq name="$list.data.hjschool_id" value="$vo.id" }
                      selected
                    {/eq}
                  {/present}>
                    {$vo.title}
                  </option>
                {/volist}
              </select>
            </div>
          </div>
          <div class="layui-form-item">
              <label for="fzshijian" class="layui-form-label">
                  <span class="x-red">*</span>获奖时间
              </label>
              <div class="layui-input-block">
                  <input type="text" id="fzshijian" name="fzshijian" lay-verify="required"
                  autocomplete="off" class="layui-input " value="{$list.data.fzshijian|default=''}" placeholder="获奖时间">
              </div>
          </div>
                    <div class="layui-form-item">
            <label for="fzschool_id" class="layui-form-label"><span class="x-red">*</span>颁奖单位</label>
            <div class="layui-input-block">
              {php} $school = danweiJibie('区级','其它级');{/php}
              <select name="fzschool_id" lay-verify="required">
                <option value=""></option>
                {volist name="school" id="vo"}
                  <option value="{$vo.id}"
                  {present name="$list.data.fzschool_id"}
                    {eq name="$list.data.fzschool_id" value="$vo.id" }
                      selected
                    {/eq}
                  {/present}>
                    {$vo.title}
                  </option>
                {/volist}
              </select>
            </div>
          </div>
          <div class="layui-form-item">
            <label for="jiangxiang_id" class="layui-form-label">
              <span class="x-red">*</span>奖项
            </label>
            <div class="layui-input-block">
              {php} $category = categoryChildren(113);{/php}
              <select name="jiangxiang_id" lay-verify="required">
                <option value=""></option>
                {volist name="category" id="vo"}
                  <option value="{$vo.id}"
                  {present name="$list.data.jiangxiang_id"}
                    {eq name="$list.data.jiangxiang_id" value="$vo.id" }
                      selected
                    {/eq}
                  {/present}>
                    {$vo.title}
                  </option>
                {/volist}
              </select>
            </div>
          </div>
          <div class="layui-form-item" style="text-align: right;">
              <button  class="layui-btn" lay-filter="mysubmit" lay-submit="">
                  {$list.set.butname}
              </button>
          </div>
      </form>
{/block}

{block name="myjs"}

<script>
  // 日期控件
  layui.use(['laydate','form','upload'], function(){
    var laydate = layui.laydate
        ,form = layui.form
        ,upload = layui.upload;
    //执行一个laydate实例
    laydate.render({
      elem: '#fzshijian' //指定元素
      ,trigger: 'click' //采用click弹出
    });

    //执行实例
    var uploadInst = upload.render({
      elem: '#upload' //绑定元素
      ,url: "/rongyu/danwei/upload" //上传接口
      ,done: function(res){
        if(res.val == true){
          $('#url').val(res.url);
          document.getElementById("img").src="__UPLOAD__/"+res.url;
        }
        layer.msg(res.msg);
      }
      ,data: {
        text: '单位荣誉'
        ,serurl:'rongyu_school'
      }
      ,acceptMime:'.jpg,.jpeg,.png'
      ,exts:'jpg|jpeg|png'
      ,auto:true
      ,error: function(){
        //请求异常回调
      }
    });
  });

  var cjgl = parent.layui.cjgl;

  // 搜索教师
  $('#cySearch').bind({
    keyup:function(){
      var val = $.trim($(this).val());
      if(val.length>0){
        cjgl.searchTeacher(this, val, 'teachers[]', 'addTeacher');
      }
    },
  })


  // 图片放大
  function imgMax(obj,max=false)
  {
    if(max == true){
      $(obj).css("max-width","800px");
      $(obj).css("max-height","1000px");
      $(obj).attr('onclick',"imgMax(this)");
    }else{
      $(obj).css("max-width","500px");
      $(obj).css("max-height","300px");
      $(obj).attr('onclick',"imgMax(this,true)");
    }
  }


</script>
{/block}

